<template>
	<view class="uni-list-cell">
		<view class="uni-list-cell-pd" style="width: 100%;">
			<view v-if="title != ''">
				{{title}}
			</view>
			<block v-if="type == 'textarea'">
				<textarea :placeholder="placeholder" class="pref-ta" :class="inputClass" :value="value" @input="_input">
				</textarea>
			</block>
			<block v-else>
				<input :type="inputType" :placeholder="placeholder" class="pref-input2" :class="inputClass" :value="value" @input="_input"/>
			</block>
		</view>
	</view>
</template>

<script>
	export default {
		name: 'edit-text',
		props: {
			title: {
				type: String,
				default: '',
			},
			inputType: {
				type: String,
				default: 'text'
			},
			inputClass: {
				type: String,
				default: ''
			},
			type: {
				type: String,
				default: 'text'
			},
			name: {
				type: String,
				default: ''
			},
			value: {
				type: String | Array,
				default: ''
			},
			placeholder: {
				type: String,
				default: ''
			}
		},
		data() {
			return {
				prefInputClass: 'pref-input',
			}
		},
		methods: {
			_input(e) {
				e.target.name = this.name
				console.log(e);
				this.$emit('input', e)
			}
		},
	}
</script>

<style>
	.pref-input2 {
		width: 100%;
		text-align: left;
		margin-right: 20upx;
		min-height: 1.4rem;
		line-height: 1.4rem;
	}
	
	.pref-ta {
		font-size: 26upx;
		height: 150upx;
		margin-top: 20upx;
	}

	.placeholder {
		min-height: 1.4rem;
		line-height: 1.4rem;
	}
</style>
